﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JV.Com.Business
{
    public enum RequestType
    {
        GetMachines,
        GetLastNews,
        GetLastNewsFrom,
        SearchGames,
        GetSuggestions,
        GetNews,
        GetGame,
        GetGameDetails,
        GetGameScreenshots,
        GetGameTest,
        GetGamePreview,
        GetFolder,
        GetFolderFrom,
        GetFolderScreenshots,
        GetLastArticles,
        GetLastArticlesFrom,
    }

    public static class RequestUrl
    {
        private static string m_domain = "http://ws.jeuxvideo.com/";

        private static readonly Dictionary<RequestType, string> m_requestUrls = new Dictionary<RequestType, string>()
        {
            { RequestType.GetMachines, string.Concat(m_domain, "00.machines_version.xml") },
            { RequestType.GetLastNews, string.Concat(m_domain, "02.flux_news.xml") },
            { RequestType.GetLastNewsFrom, string.Concat(m_domain, "02.flux_news-{0}.xml") },
            { RequestType.SearchGames, string.Concat(m_domain, "search_n/{0}") },
            { RequestType.GetSuggestions, string.Concat(m_domain, "search_sug/{0}") },
            { RequestType.GetNews, string.Concat(m_domain, "02.news/{0}.xml") },
            { RequestType.GetGame, string.Concat(m_domain, "01.jeux/{0}.xml") },
            { RequestType.GetGameDetails, string.Concat(m_domain, "01.jeux/details/{0}.xml") },
            { RequestType.GetGameScreenshots, string.Concat(m_domain, "01.jeux/screen/{0}.xml") },
            { RequestType.GetFolderScreenshots, string.Concat(m_domain, "03.dossier/{0}/{1}.xml") },
            { RequestType.GetGameTest, string.Concat(m_domain, "03.test_complet/{0}.xml") },
            { RequestType.GetGamePreview, string.Concat(m_domain, "03.preview/{0}.xml") },
            { RequestType.GetLastArticles, string.Concat(m_domain, "03.flux_articles_{0}.xml") },
            { RequestType.GetLastArticlesFrom, string.Concat(m_domain, "03.flux_articles_{0}-{1}.xml") },
            { RequestType.GetFolder, string.Concat(m_domain, "03.dossier/{0}.xml") },
            { RequestType.GetFolderFrom, string.Concat(m_domain, "03.dossier/{0}/{1}.xml") },
        };

        public static string Get(RequestType type, params object[] formats)
        {
            return string.Format(m_requestUrls[type], formats);
        }
    }
}
